package binarySearch;

public class BinarySearch704 {
    public int search(int[] nums, int target) {
        return search(nums, target, 0, nums.length - 1);

    }

    private int search(int[] nums, int target, int begin, int end) {
        if (begin > end) {
            return -1;
        }

        int mid = (begin + end) / 2;

        if (nums[mid] == target) {
            return mid;
        }

        return  nums[mid]>target?search(nums,target,begin,mid-1)
                :search(nums, target, mid+1, end);
    }

}
